package com.winning.jsyd;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.winning.jsyd.ws.ISupHibms;
import com.winning.jsyd.ws.ISupHibmsService;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author z_dd@winning.com.cn
 * @date 2019/4/23 10:55
 */
@SpringBootApplication
@Slf4j
public class JsydSjscApplication {

    @Value("${jsyd.dataupload.wsdlLocation}")
    private String wsdlLocation;

    public static void main(String[] args) {
        SpringApplication.run(JsydSjscApplication.class, args);
    }

    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    @Bean
    public ISupHibms iSupHibms() {
        try {
            ISupHibmsService iSupHibmsService = new ISupHibmsService(new URL(wsdlLocation));
            return iSupHibmsService.getISupHibmsPort();
        } catch (MalformedURLException e) {
            log.error("上传接口[{}]连接通信失败!", wsdlLocation);
            throw new RuntimeException(e);
        }
    }


}
